using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace 纺织贸易管理系统
{
    public static class FahuoDanService
    {
        public static List<FahuoDan> GetFahuoDanlst(Expression<Func<FahuoDan,bool>> func)
         {
            return  Connect.dbcontext.Queryable<FahuoDan>().Where (func).ToList ();
         }
        public static FahuoDan GetOneFahuoDan(Expression<Func<FahuoDan, bool>> func)
         {
            return  Connect.CreatConnect().QueryOneResult<FahuoDan>(func);
         }
        public static void InsertFahuoDan(List<FahuoDan> FahuoDanObjs)
         {
              Connect.dbcontext.Insertable<FahuoDan>(FahuoDanObjs).ExecuteCommand ();
         }
        public static void InsertFahuoDan(FahuoDan FahuoDanObj)
         {
            Connect.dbcontext.Insertable<FahuoDan>(FahuoDanObj).ExecuteCommand();
        }
        public static void UpdateFahuoDan(FahuoDan FahuoDanObj, Expression<Func<FahuoDan, bool>> func)
         {
              Connect.CreatConnect().Update<FahuoDan>(FahuoDanObj,func);
         }
        public static void DeleteFahuoDan(Expression<Func<FahuoDan, bool>> func)
         {
              Connect.dbcontext.Deleteable<FahuoDan>(func).ExecuteCommand();
         }
        public static List<JuanHaoTable > QueryJuanhaotableFromShipments(List<FahuoDan >shipments)
        {
            var juanhaos = shipments.Select(item => item.jh).ToList();
            return Connect.dbcontext.Queryable<JuanHaoTable>().Where(x=>juanhaos.Contains(x.JuanHao )).ToList ();
        }
    }
}
